package stu.aistar.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import stu.aistar.model.pojo.Area;

import java.util.List;

@Component
public interface AreaMapper {

    @Select("SELECT a1.id,a1.`Name` from area a1,area a2 WHERE a2.pid = 0 and a1.Pid = a2.id and a1.`Name`!='市辖区' order by a1.id desc")
    List<Area> findCitys();

    @Select("SELECT a1.id,a1.name,a2.name FROM area a1,area a2 WHERE a1.pid=a2.id AND a2.pid !=0 and a1.pid=#{pid} and a1.`Name`!='市辖区';")
    List<Area> findAreas(@Param("pid") Integer pid);
}
